import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_boost/flutter_boost.dart';
import 'package:oktoast/oktoast.dart' as toast;

///toast吐司，去除了类，改为全局方法
///* 显示长吐司，默认4秒
toast.ToastFuture showLongToast(
  String msg, {
  bool dismissOtherToast = false,
}) =>
    dkShowToast(msg,
        duration: Duration(milliseconds: 4000),
        position: toast.ToastPosition.bottom,
        dismissOtherToast: dismissOtherToast);

///toast吐司，去除了类，改为全局方法
///* 显示长吐司，默认2.3秒
toast.ToastFuture showShortToast(
  String msg, {
  bool dismissOtherToast = false,
}) =>
    dkShowToast(msg,
        duration: Duration(milliseconds: 2300),
        position: toast.ToastPosition.bottom,
        dismissOtherToast: dismissOtherToast);

///toast吐司，去除了类，改为全局方法
///* 显示屏幕居中的吐司，默认2.3秒
toast.ToastFuture showCenterToast(
  String msg, {
  bool dismissOtherToast = false,
  duration = const Duration(milliseconds: 2300),
}) =>
    dkShowToast(msg,
        position: toast.ToastPosition.center,
        duration: duration,
        dismissOtherToast: dismissOtherToast);

///toast吐司，去除了类，改为全局方法
///* 取消当前显示的吐司
void cancelToast() => toast.dismissAllToast();

///toast吐司，去除了类，改为全局方法
///* 默认通用吐司，由于和OkToast库中的方法重名，因此加了前缀
toast.ToastFuture dkShowToast(
  String msg, {
  Duration duration = const Duration(milliseconds: 2300),
  toast.ToastPosition position,
  TextStyle textStyle,
  EdgeInsetsGeometry textPadding,
  Color backgroundColor,
  double radius,
  VoidCallback onDismiss,
  TextDirection textDirection,
  bool dismissOtherToast = false,
  TextAlign textAlign,
}) =>
    toast.showToast(
      msg,
      context: FlutterBoost.singleton.containerManagerKey.currentContext,
      duration: duration,
      position: position,
      textStyle: textStyle,
      textPadding: textPadding,
      backgroundColor: backgroundColor,
      radius: radius,
      onDismiss: onDismiss,
      textDirection: textDirection,
      dismissOtherToast: dismissOtherToast,
      textAlign: textAlign,
    );

///toast吐司，去除了类，改为全局方法
///* 显示自定义吐司
toast.ToastFuture showWidgetToast(
  Widget widget, {
  Duration duration = const Duration(milliseconds: 2300),
  VoidCallback onDismiss,
  bool dismissOtherToast,
  TextDirection textDirection,
  toast.ToastPosition position,
}) =>
    toast.showToastWidget(widget,
        context: FlutterBoost.singleton.containerManagerKey.currentContext,
        duration: duration,
        onDismiss: onDismiss,
        dismissOtherToast: dismissOtherToast,
        textDirection: textDirection,
        position: position);
